#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <map>
#include <climits>
#include <sstream>
using namespace std;


int main(){
    string s;
    getline(cin,s);
    istringstream icin(s);
    vector<int> v;
    int t;
    while(icin >> t){
        v.push_back(t);
    }
    int n =v.size();
    int x=0,y=-1;
    for(int i=0;i<n-1;i++){
        if(v[i+1]<v[i]){
            if(-1==y){
                y=i;
                continue;
            }
            x=i+1;
            break;
        }
    }
    if(x<y){
        cout << x+1 << " " << y+1 <<endl;
    }else{
        cout << y+1 << " " << x+1<<endl;
    }

    return 0;
}